import {messageType} from "element-plus";

/**
 * 封装一个返回true和false的对话框
 * @param title
 * @param elType 弹框类型 ,比如warning
 */
export function openConfirm(title: string, elType: messageType = 'warning'): Promise<boolean> {
    return new Promise((resolve, reject) => {
        ElMessageBox.confirm(
            `${title}?`,
            '警告',
            {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: elType,
            }
        )
            .then(() => {
                resolve(true)
            })
            .catch(() => {
                resolve(false)
            })
    })

}